import tkinter as tk

import customtkinter as ctk

from Attriabte.TextArea import Version, VersionInfo

image_left = ...
image_center = ...
image_right = ...

from View.WindowComponent.BodyFrame.BodyFrame import BodyFrame


class MainFrame(BodyFrame):

    """
    主菜单Frame
    """

    def __init__(self, layout, with_scoller=False):
        global image_left, image_right, image_center
        super().__init__(layout, with_scoller)


    def footer(self, frame):
        ctk.CTkLabel(master=frame, text="版本:"+Version, text_font=('黑体', 17)).pack()
        ctk.CTkLabel(master=frame, text=VersionInfo, text_font=('黑体', 12)).pack(anchor=tk.W)


    def valueto(self, frame, title, info, image):
        ctk.CTkLabel(master=frame, text=title, text_font=('黑体', 17)).pack(pady=32)
        ctk.CTkLabel(frame, image=image).pack()
        ctk.CTkLabel(frame, text=info, text_font=('黑体', 13) ).pack(pady=32)

    def pack(self):
        block_height = .5
        block_width = .3
        margin = .02

        rely = (1 - block_height) / 4
        relx = (1 - (margin * 2 + block_width * 3)) / 2

        frame_left = ctk.CTkFrame(self.frame, corner_radius=10)
        frame_center = ctk.CTkFrame(self.frame, corner_radius=10)
        frame_right = ctk.CTkFrame(self.frame, corner_radius=10)

        frame_left.place(rely=rely, relx=relx, relwidth=block_width, relheight=block_height)
        frame_center.place(rely=rely, relx=relx + (block_width + margin) * 1, relwidth=block_width,
                           relheight=block_height)
        frame_right.place(rely=rely, relx=relx + (block_width + margin) * 2, relwidth=block_width,
                          relheight=block_height)


        frame_button = ctk.CTkFrame(self.frame, corner_radius=0, )
        rely2 = .80
        frame_button.place(relx=0, rely=rely2, relheight=1 - rely2, relwidth=1)

        self.valueto(frame_left, "第一步", "添加单词",self.layout.app.image_left)
        self.valueto(frame_center, "第二步", "进行所添加的学习", self.layout.app.image_center)
        self.valueto(frame_right, "第三步", "复习", self.layout.app.image_right)
        self.footer(frame_button)